/*
 * CSurface.cpp
 *
 *  Created on: 22/12/2012
 *
 */

#include "CSurface.h"
#include <SDL/SDL_image.h>

	CSurface::CSurface() {

	}

	SDL_Surface* CSurface::onLoad(char* file){
		SDL_Surface* surfTemp = NULL;
		SDL_Surface* surfReturn = NULL;

		if((surfTemp = IMG_Load(file)) == NULL){
			return NULL;
		}

		surfReturn = SDL_DisplayFormatAlpha(surfTemp);
		SDL_FreeSurface(surfTemp);
		surfTemp = NULL;
		return surfReturn;
	}

	bool CSurface::onDraw(SDL_Surface* surfDest, SDL_Surface* surfSource, int x, int y){
		if(surfDest == NULL || surfSource == NULL){
			return false;
		}

	SDL_Rect destRect;

	destRect.x = x;
	destRect.y = y;

	SDL_BlitSurface(surfSource, NULL, surfDest, &destRect);
	return true;
}
